<?php
    include_once '../config.php';

    if ($_COOKIE['LOG'] == false) {
        header('Location: ../index.php');
    }

    include '../layout/header.php';

    $project_nr = $_GET['project_nr'];
    $client_id  = $_GET['client_id'];
    $sql = "SELECT * FROM project p LEFT JOIN address a ON (a.address_id = p.address_id) LEFT JOIN `client` c ON "
         . "(c.client_id = p.client_id) WHERE project_nr = '" . $project_nr . "'";
    $result = mysql_query($sql);
    $data = mysql_fetch_array($result);
?>
<body>
    <div data-role="page">
        <div data-role="header" data-theme="b" class="ui-overlay-shadow">
            <h1>A <?php echo $project_nr; ?></h1>
            <a href="index.php" data-role="button" data-icon="back" class="ui-btn-left" data-theme="a">Liste</a>
        </div>
        <div data-role="content" data-theme="c">
            <!-- Fehlermeldungen von edit -->
            <?php
                if ($_GET['km'] == 'no') {
            ?>
            <ul class="ui-listview ui-listview-inset ui-corner-all ui-shadow" data-inset="true" data-role="listview">
                <li class="ui-li ui-li-static ui-body-c ui-corner-top">
                    <table align="center">
                        <tr>
                            <td style="vertical-align: middle">
                                <img src="../assets/images/alert.png" width="34px" />
                            </td>
                            <td width="20px"></td>
                            <td style="vertical-align: middle">
                                <font style="color:red">Ein Kaufmann muss ausgef&uuml;llt werden!</font>
                            </td>
                        </tr>
                    </table>
                </li>
            </ul>
            <?php
                } else if ($_GET['km'] == 'name') {
            ?>
            <ul class="ui-listview ui-listview-inset ui-corner-all ui-shadow" data-inset="true" data-role="listview">
                <li class="ui-li ui-li-static ui-body-c ui-corner-top">
                    <table align="center">
                        <tr>
                            <td style="vertical-align: middle">
                                <img src="../assets/images/alert.png" width="34px" />
                            </td>
                            <td width="20px"></td>
                            <td style="vertical-align: middle">
                                <font style="color:red">Das Namensfeld beim Kaufmann wurde nicht ausgef&uuml;llt!</font>
                            </td>
                        </tr>
                    </table>
                </li>
            </ul>
            <?php
                }
            ?>
            <!-- Fehlermeldungen von edit -->
            <!-- Fehlermeldungen von assumed -->
            <?php
                if ($_GET['assumed'] == 'nr') {
            ?>
            <ul class="ui-listview ui-listview-inset ui-corner-all ui-shadow" data-inset="true" data-role="listview">
                <li class="ui-li ui-li-static ui-body-c ui-corner-top">
                    <table align="center">
                        <tr>
                            <td style="vertical-align: middle">
                                <img src="../assets/images/alert.png" width="34px" />
                            </td>
                            <td width="20px"></td>
                            <td style="vertical-align: middle">
                                <font style="color:red">Die Bestell- & Projektnr. des Auftraggebers müssen ausgefüllt sein!</font>
                            </td>
                        </tr>
                    </table>
                </li>
            </ul>
            <?php
                } else if ($_GET['assumed'] == 'no') {
            ?>
            <ul class="ui-listview ui-listview-inset ui-corner-all ui-shadow" data-inset="true" data-role="listview">
                <li class="ui-li ui-li-static ui-body-c ui-corner-top">
                    <table align="center">
                        <tr>
                            <td style="vertical-align: middle">
                                <img src="../assets/images/alert.png" width="34px" />
                            </td>
                            <td width="20px"></td>
                            <td style="vertical-align: middle">
                                <font style="color:red">Ein Projektleiter muss ausgef&uuml;llt werden!</font>
                            </td>
                        </tr>
                    </table>
                </li>
            </ul>
            <?php
                } else if ($_GET['assumed'] == 'name') {
            ?>
            <ul class="ui-listview ui-listview-inset ui-corner-all ui-shadow" data-inset="true" data-role="listview">
                <li class="ui-li ui-li-static ui-body-c ui-corner-top">
                    <table align="center">
                        <tr>
                            <td style="vertical-align: middle">
                                <img src="../assets/images/alert.png" width="34px" />
                            </td>
                            <td width="20px"></td>
                            <td style="vertical-align: middle">
                                <font style="color:red">Das Namensfeld beim Projektleiter wurde nicht ausgef&uuml;llt!</font>
                            </td>
                        </tr>
                    </table>
                </li>
            </ul>
            <?php
                }
            ?>
            <!-- Fehlermeldungen von edit -->
            <h1 align="center">A <?php echo $project_nr; ?></h1>
            <h3 align="center">Status:
            <?php
                if ($data['get'] == 0) {
                    echo '<font style="color:#2666db">Noch offen</font>';
                } else if ($data['get'] == 1) {
                    echo '<font style="color:green">Auftrag</font>';
                } else if ($data['get'] == 3) {
                    echo '<font style="color:green">Auftrag & Erledigt</font>';
                } else if ($data['get'] == 4) {
                    echo '<font style="color:#2666db">Zurückgestellt</font>';
                } else {
                    echo '<font style="color:red">Kein Auftrag</font>';
                }
            ?>
            </h3>
            <?php
                if ($data['get'] == 0) {
                    include_once 'form/open.php';
                } else if ($data['get'] == 1) {
                    include_once 'form/assumed.php';
                } else if ($data['get'] == 2) {
                    include_once 'view/dont.php';
                } else if ($data['get'] == 3) {
                    include_once 'view/accept.php';
                } else {
                    include_once 'form/stopped.php';
                }
            ?>
        </div>
    </div>
</body>
</html>